/**
 * Created by bgy on 2016/12/5.
 * 选择质检方式
 */
import React from 'react';
import {hashHistory} from 'react-router';

import HeaderTitle from '../../components/common/HeaderTitle';

var SelectQTWay = React.createClass({

  getInitialState(){
    let qcApply = JSON.parse(window.localStorage.getItem('qcApply'));
    if(qcApply.type == 'A'){
      return{type:'placeQT'};
    }else{
      return{type:'sendQT'};
    }
  },
  componentDidMount:function () {

  },
  handlerClick() {
    let qcApply = JSON.parse(window.localStorage.getItem('qcApply'));
    if(this.state.type == 'placeQT'){
      qcApply.type = 'A';
    }else{
      qcApply.type = 'B';
    }
    window.localStorage.setItem('qcApply',JSON.stringify(qcApply));
    const path = this.state.type;
    hashHistory.push(path);
  },

  handlerCheck(event) {
    this.setState({
      type:event.target.value
    })
  },
  render() {
    return (
      <div className="SelectQTWay">
        <HeaderTitle title="选择质检方式"/>
        <div className="content">
          <h2 style={{marginTop:'20px'}}>选择质检方式</h2>
          <div className="qtDiv">
            <div className="qtTitle">
              <input type="radio" name="qtWay" defaultChecked ={this.state.type == 'placeQT' ? true:false} value="placeQT" onClick={this.handlerCheck} style={{fontSize:'20px'}}/>&nbsp;&nbsp;<h2>产地质检</h2>
            </div>
            <div className="qtDetail">
              产地之间的适用范围、流程、作用及收费介绍
            </div>
          </div>
          <div className="qtDiv">
            <div className="qtTitle">
              <input type="radio" name="qtWay" defaultChecked ={this.state.type == 'sendQT' ? true:false} value="sendQT" onClick={this.handlerCheck}  style={{fontSize:'20px'}}/>&nbsp;&nbsp;<h2>快递送检</h2>
            </div>
            <div className="qtDetail">
              产地之间的适用范围、流程、作用及收费介绍
            </div>
          </div>
          <button style={{marginTop:'200px'}} className="button button-pill button-primary btn-green btn-long" onClick={this.handlerClick} ref="loginBtn">下一步</button>
        </div>
      </div>
    )
  }
})
export default SelectQTWay;
